﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using F_MODEL;
using System.Data;
using System.Data.SqlClient;

namespace F_DAL
{

    /// <summary>
    /// 带货处理
    /// </summary>
   public class CarryGargo_dal
    {

       /// <summary>
       /// 带货
       /// </summary>
       /// <returns></returns>
       public List<Temp> AllList(int id)
       {
            SqlParameter[] paramter ={
                               new  SqlParameter("@Userid",SqlDbType.Int){Value=id}
                               };
            SqlDataReader read = DbHelperSQL.RunProcedure("ParcelIno_All", paramter);
            List<Temp> list = new List<Temp>();
            while (read.Read())
            {
                Temp us = new Temp();
                us.destination = read["destination"].ToString();
                us.destinationTime =Convert.ToDateTime( read["destinationTime"]);
                us.flightInfo = read["flightInfo"].ToString();
                us.freeSpace = Convert.ToDecimal(read["freeSpace"]);
                us.goodsImg = read["goodsImg"].ToString();
                us.goodsType = Convert.ToInt32(read["goodsType"]);
                us.mailId = read["mailId"].ToString();
                us.mailIsDel = Convert.ToInt32(read["mailIsDel"].ToString());
                us.mailTimeSpan = Convert.ToDateTime(read["mailTimeSpan"].ToString());
                us.origin = read["origin"].ToString();
                us.originTime = Convert.ToDateTime(read["originTime"].ToString());
                us.parcelId = Convert.ToInt32(read["parcelId"].ToString());
                us.predictPrice = Convert.ToDecimal(read["predictPrice"].ToString());
                us.proof = read["proof"].ToString();
                us.receiveUser = read["receiveUser"].ToString();
                us.sendUser = read["sendUser"].ToString();
                us.stationId = 1;
                us.stationName = read["stationName"].ToString();
                us.submitTime = Convert.ToDateTime(read["submitTime"].ToString());
                us.userId = Convert.ToInt32(read["userId"].ToString());
                us.waybillId = Convert.ToString(read["waybillId"]);
                us.dweight = Convert.ToString(read["dweight"]);
                us.wmmIsDel = Convert.ToInt32(read["wmmIsDel"].ToString());
                us.wmmTimeSpan = Convert.ToDateTime(read["wmmTimeSpan"].ToString());
                us.WorkMan = read["WorkMan"].ToString();
                us.WorkManTel = read["WorkManTel"].ToString();
                list.Add(us);
            }
            return list;
       
       }

       /// <summary>
       /// 带货的领取代金券
       /// </summary>
       /// <param name="userid"></param>
       /// <param name="mon"></param>
       /// <returns></returns>
       public int getcou(int userid, int mon)
       {
           SqlParameter[] paramter ={
                               new  SqlParameter("@userid",SqlDbType.Int){Value=userid},
                               new SqlParameter("@mon",SqlDbType.Int){Value=mon}
                               };
           return Convert.ToInt32(DbHelperSQL.RunProcedureReturnSingle("[GetCoup]",paramter));
           
       }

    }
}
